/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author user
 */
@Entity
@NamedQueries(
   value={@NamedQuery(name="chercherJoueur", query="select object(j) from Joueur j where j.pseudo= :pseudo and j.mdp= :mdp" ),
        @NamedQuery(name="chercherPseudo", query="select object(j) from Joueur j where j.pseudo= :pseudo" )
   }
)
public class Joueur implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    private String pseudo;
    private String mdp;
    private String mail;
    private int nbParties;
    private int nbPartiesGagnees;

    public Joueur(){
        pseudo="";
        mdp="";
        mail="";
        nbParties=0;
        nbPartiesGagnees=0;
    }
    
    public Joueur(String pseudo, String mdp,String mail){
        this.pseudo=pseudo;
        this.mdp=mdp;
        this.mail=mail;
        nbParties=0;
        nbPartiesGagnees=0;
    }
    
    public String getMail() {
        return mail;
    }

    public void setMail(String mail) {
        this.mail = mail;
    }

    public String getMdp() {
        return mdp;
    }

    public void setMdp(String mdp) {
        this.mdp = mdp;
    }

    public int getNbParties() {
        return nbParties;
    }

    public void setNbParties(int nbParties) {
        this.nbParties = nbParties;
    }

    public int getNbPartiesGagnees() {
        return nbPartiesGagnees;
    }

    public void setNbPartiesGagnees(int nbPartiesGagnees) {
        this.nbPartiesGagnees = nbPartiesGagnees;
    }

    public String getPseudo() {
        return pseudo;
    }

    public void setPseudo(String pseudo) {
        this.pseudo = pseudo;
    }
    public String getJoueurPseudo(){      
        return pseudo;
    }
    
    public void ajouterPartie(){
        nbParties++;
    }
    
    public void ajouterPartieGagnee(){
        nbPartiesGagnees++;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Joueur)) {
            return false;
        }
        Joueur other = (Joueur) object;
        if ((this.pseudo == null && other.pseudo != null) || (this.pseudo != null && !this.pseudo.equals(other.pseudo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Joueur[ pseudo=" + pseudo + " ]";
    }
    
}
